
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 11/21/2014 15:48:25
-- Generated from EDMX file: C:\Users\cvega\Desktop\Cesar Settings\SampleProjects\iNVOICE\iNVOICE\iNVOICE\Models\UserInfoModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [aspnet-iNVOICE-20141107031422];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[AspNetUsers]', 'U') IS NOT NULL
    DROP TABLE [dbo].[AspNetUsers];
GO
IF OBJECT_ID(N'[dbo].[Clients]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Clients];
GO
IF OBJECT_ID(N'[dbo].[Companies]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Companies];
GO
IF OBJECT_ID(N'[dbo].[Countries]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Countries];
GO
IF OBJECT_ID(N'[dbo].[FormElementTemplates]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FormElementTemplates];
GO
IF OBJECT_ID(N'[dbo].[FormQuestions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FormQuestions];
GO
IF OBJECT_ID(N'[dbo].[Products]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Products];
GO
IF OBJECT_ID(N'[dbo].[PurchasedProducts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PurchasedProducts];
GO
IF OBJECT_ID(N'[dbo].[StatesOfUSAs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[StatesOfUSAs];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'AspNetUsers'
CREATE TABLE [dbo].[AspNetUsers] (
    [Id] nvarchar(128)  NOT NULL,
    [Email] nvarchar(256)  NULL,
    [EmailConfirmed] bit  NOT NULL,
    [PasswordHash] nvarchar(max)  NULL,
    [SecurityStamp] nvarchar(max)  NULL,
    [PhoneNumber] nvarchar(max)  NULL,
    [PhoneNumberConfirmed] bit  NOT NULL,
    [TwoFactorEnabled] bit  NOT NULL,
    [LockoutEndDateUtc] datetime  NULL,
    [LockoutEnabled] bit  NOT NULL,
    [AccessFailedCount] int  NOT NULL,
    [UserName] nvarchar(256)  NOT NULL
);
GO

-- Creating table 'Clients'
CREATE TABLE [dbo].[Clients] (
    [ClientId] int IDENTITY(1,1) NOT NULL,
    [CompanyId] int  NOT NULL,
    [BusinessName] varchar(100)  NULL,
    [ContactName] nvarchar(100)  NULL,
    [FirstName] nvarchar(100)  NULL,
    [LastName] nvarchar(100)  NULL,
    [Zipcode] varchar(10)  NULL,
    [BillingAddress] varchar(100)  NULL,
    [PhoneNumber] varchar(100)  NULL,
    [ShippingAddress] varchar(100)  NULL,
    [Mobile] varchar(100)  NULL,
    [Fax] varchar(100)  NULL,
    [WebsiteUrl] varchar(100)  NULL,
    [State] varchar(100)  NULL,
    [PicURL] varchar(100)  NULL,
    [Email] varchar(100)  NULL,
    [City] nvarchar(100)  NULL,
    [Created] datetime  NOT NULL,
    [CreatedBy] nvarchar(50)  NOT NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL,
    [ClientFullName] nvarchar(max)  NULL,
    [ClientTitle] nvarchar(max)  NULL,
    [ClientFirstName] nvarchar(max)  NULL,
    [ClientLastName] nvarchar(max)  NULL,
    [ClientPassword] nvarchar(max)  NULL,
    [ClientProject] nvarchar(max)  NULL,
    [ClientProjectId] nvarchar(max)  NULL,
    [ClientAddress] nvarchar(max)  NULL,
    [ClientPhone] nvarchar(max)  NULL,
    [ClientEmail] nvarchar(max)  NULL,
    [ClientCompany] nvarchar(max)  NULL,
    [ClientQuestions] nvarchar(max)  NULL,
    [ClientEmailSubject] nvarchar(max)  NULL,
    [ClientEmailBody] nvarchar(max)  NULL,
    [AdminEmailAddress] nvarchar(max)  NULL,
    [ClientProjectTemplate] nvarchar(max)  NULL
);
GO

-- Creating table 'Companies'
CREATE TABLE [dbo].[Companies] (
    [CompanyId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [BusinessName] varchar(100)  NULL,
    [ContactName] nvarchar(100)  NULL,
    [FirstName] nvarchar(100)  NULL,
    [LastName] nvarchar(100)  NULL,
    [Zipcode] varchar(10)  NULL,
    [BillingAddress] varchar(100)  NULL,
    [PhoneNumber] varchar(100)  NULL,
    [ShippingAddress] varchar(100)  NULL,
    [Mobile] varchar(100)  NULL,
    [Fax] varchar(100)  NULL,
    [WebsiteUrl] varchar(100)  NULL,
    [State] varchar(100)  NULL,
    [PicURL] varchar(100)  NULL,
    [Email] varchar(100)  NULL,
    [City] nvarchar(100)  NULL,
    [Created] datetime  NOT NULL,
    [CreatedBy] nvarchar(50)  NOT NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL
);
GO

-- Creating table 'Countries'
CREATE TABLE [dbo].[Countries] (
    [Id] varchar(2)  NOT NULL,
    [name] varchar(64)  NOT NULL
);
GO

-- Creating table 'FormElementTemplates'
CREATE TABLE [dbo].[FormElementTemplates] (
    [FormElementsTemplateId] int IDENTITY(1,1) NOT NULL,
    [InputType] nvarchar(max)  NULL,
    [TemplateUrl] nvarchar(max)  NULL,
    [group] nvarchar(max)  NULL,
    [CreatedBy] nvarchar(max)  NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL
);
GO

-- Creating table 'FormQuestions'
CREATE TABLE [dbo].[FormQuestions] (
    [FormQuestionId] int IDENTITY(1,1) NOT NULL,
    [FormElementsTemplateId] nvarchar(max)  NULL,
    [Question] nvarchar(max)  NULL,
    [label] nvarchar(max)  NULL,
    [InputType] nvarchar(max)  NULL,
    [name] nvarchar(max)  NULL,
    [id] nvarchar(max)  NULL,
    [class] nvarchar(max)  NULL,
    [placeholder] nvarchar(max)  NULL,
    [value] nvarchar(max)  NULL,
    [option] nvarchar(max)  NULL,
    [group] nvarchar(max)  NULL,
    [CreatedBy] nvarchar(max)  NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL
);
GO

-- Creating table 'Products'
CREATE TABLE [dbo].[Products] (
    [ProductId] int IDENTITY(1,1) NOT NULL,
    [CompanyId] int  NOT NULL,
    [ProductName] nvarchar(100)  NULL,
    [ProductDescription] varchar(100)  NULL,
    [ProductPrice] nvarchar(100)  NULL,
    [ProductImageUrl] nvarchar(max)  NULL,
    [Created] datetime  NOT NULL,
    [CreatedBy] nvarchar(50)  NOT NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL
);
GO

-- Creating table 'PurchasedProducts'
CREATE TABLE [dbo].[PurchasedProducts] (
    [PurchasedProductsId] int IDENTITY(1,1) NOT NULL,
    [ClientId] int  NOT NULL,
    [BusinessName] varchar(100)  NULL,
    [ContactName] nvarchar(100)  NULL,
    [BillingAddress] varchar(100)  NULL,
    [PhoneNumber] varchar(100)  NULL,
    [Zipcode] varchar(10)  NULL,
    [ShippingAddress] varchar(100)  NULL,
    [Mobile] varchar(100)  NULL,
    [City] nvarchar(100)  NULL,
    [State] varchar(100)  NULL,
    [InvouceId] int  NULL,
    [ProductId] int  NOT NULL,
    [ProductPrice] nvarchar(100)  NULL,
    [ProductName] nvarchar(100)  NULL,
    [ProductDescription] varchar(100)  NULL,
    [ProductsAmount] nvarchar(100)  NULL,
    [ProductImageUrl] nvarchar(100)  NULL,
    [PurchasedOrderNumber] nvarchar(100)  NULL,
    [Created] datetime  NOT NULL,
    [CreatedBy] nvarchar(50)  NOT NULL,
    [Updated] datetime  NULL,
    [UpdatedBy] nvarchar(50)  NULL
);
GO

-- Creating table 'StatesOfUSAs'
CREATE TABLE [dbo].[StatesOfUSAs] (
    [Id] varchar(2)  NOT NULL,
    [name] varchar(64)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'AspNetUsers'
ALTER TABLE [dbo].[AspNetUsers]
ADD CONSTRAINT [PK_AspNetUsers]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [ClientId] in table 'Clients'
ALTER TABLE [dbo].[Clients]
ADD CONSTRAINT [PK_Clients]
    PRIMARY KEY CLUSTERED ([ClientId] ASC);
GO

-- Creating primary key on [CompanyId] in table 'Companies'
ALTER TABLE [dbo].[Companies]
ADD CONSTRAINT [PK_Companies]
    PRIMARY KEY CLUSTERED ([CompanyId] ASC);
GO

-- Creating primary key on [Id] in table 'Countries'
ALTER TABLE [dbo].[Countries]
ADD CONSTRAINT [PK_Countries]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [FormElementsTemplateId] in table 'FormElementTemplates'
ALTER TABLE [dbo].[FormElementTemplates]
ADD CONSTRAINT [PK_FormElementTemplates]
    PRIMARY KEY CLUSTERED ([FormElementsTemplateId] ASC);
GO

-- Creating primary key on [FormQuestionId] in table 'FormQuestions'
ALTER TABLE [dbo].[FormQuestions]
ADD CONSTRAINT [PK_FormQuestions]
    PRIMARY KEY CLUSTERED ([FormQuestionId] ASC);
GO

-- Creating primary key on [ProductId] in table 'Products'
ALTER TABLE [dbo].[Products]
ADD CONSTRAINT [PK_Products]
    PRIMARY KEY CLUSTERED ([ProductId] ASC);
GO

-- Creating primary key on [PurchasedProductsId] in table 'PurchasedProducts'
ALTER TABLE [dbo].[PurchasedProducts]
ADD CONSTRAINT [PK_PurchasedProducts]
    PRIMARY KEY CLUSTERED ([PurchasedProductsId] ASC);
GO

-- Creating primary key on [Id] in table 'StatesOfUSAs'
ALTER TABLE [dbo].[StatesOfUSAs]
ADD CONSTRAINT [PK_StatesOfUSAs]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------